package test.Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

public class ExamPaperDao {
    public static ResultSet selectExamPaper(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet) throws SQLException {
        System.out.println("请输入你所要查的试卷科目：");
        Scanner scanner = new Scanner(System.in);
        String next = scanner.next();
        String[] strings = {next};
        String sql = "select * from exam_paper where subject = ?";
        preparedStatement = connection.prepareStatement(sql);
        for (int i = 0; i < strings.length; i++) {
            preparedStatement.setObject(i + 1, strings[i]);
        }
        resultSet = preparedStatement.executeQuery();
        if (resultSet != null) {
            System.out.println("查询成功");
        }
        return resultSet;
    }
}
